﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace YXShop.TemplateAction
{
    public partial class LabelParse
    {
        public string StoreSearch()
        {
            string mystyle = this.Label_Inserted;
            string str_StoreSearchForm = this.GetParamValue("YX:StoreSearchForm");
            if (!string.IsNullOrEmpty(mystyle))
            {
                if (mystyle.IndexOf("[#StoreKey]") > -1)
                {
                    mystyle = mystyle.Replace("[#StoreKey]", "<input name=\"q_StoreKey\" id=\"q_StoreKey\" type=\"text\" /> ");
                }
                if (mystyle.IndexOf("[#StoreHost]") > -1)
                {
                    mystyle = mystyle.Replace("[#StoreHost]", "<input name=\"q_StoreHost\" id=\"q_StoreHost\" type=\"text\" /> ");
                }
                if (mystyle.IndexOf("[#StoreType]") > -1)
                {
                    
                    YXShop.BLL.Shop.ShopCategory cateBll = new YXShop.BLL.Shop.ShopCategory();
                    List<YXShop.Model.Shop.ShopCategory> cateList = cateBll.GetAll();
                    StringBuilder storeTypeSel = new StringBuilder();
                    storeTypeSel.Append("<select name=\"q_StoreType\" id=\"q_StoreType\">");
                    storeTypeSel.Append("<option value=\"\">所有类型</option>");
                    if (cateList.Count > 0)
                    {
                        for (int i = 0; i < cateList.Count; i++)
                        {
                            storeTypeSel.Append("<option value=\"" + cateList[i].ID + "\">" + cateList[i].Name + "</option>");
                        }
                    }
                    storeTypeSel.Append("</select>");
                    mystyle = mystyle.Replace("[#StoreType]", storeTypeSel.ToString());
                }
                if (mystyle.IndexOf("[#SearchButton]") > -1)
                {
                    mystyle = mystyle.Replace("[#SearchButton]", "<input type=\"submit\" name=\"button\" id=\"button\" value=\"提交\" /> ");
                }
                if (mystyle.IndexOf("[#SearchButtonReste]") > -1)
                {
                    mystyle = mystyle.Replace("[#SearchButtonReste]", "<input type=\"reset\" name=\"button\" id=\"button\" value=\"重置\" /> ");
                }
            }
            return mystyle;
        }
    }
}
